package de.dlrg.wms.dummyDevice.gui;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

import wms2010.interfaces.devices.IDevice;

public class DummyDeviceGui {
	public Button btnStop;
	private static final String NL = System.getProperty("line.separator");

	protected Shell shell;
	private Text txtRumblelog;
	private IDevice device;

	public void rumbled() {
		DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Date date = new Date();
		this.txtRumblelog.append(NL + "Rumbled at " + dateFormat.format(date));
	}

	public DummyDeviceGui(IDevice device) {
		this.device = device;
		open();
	}

	/**
	 * @wbp.parser.entryPoint
	 */
	public void open() {
		System.out.println("started gui window");
		createContents();
	}

	public void createContents() {
		shell = new Shell();

		shell.setText(this.device.getName());
		
		btnStop = new Button(shell, SWT.NONE);
		btnStop.setBounds(162, 79, 94, 30);
		btnStop.setText("Stop");
		btnStop.setData(this.device);

		txtRumblelog = new Text(shell, SWT.BORDER);
		txtRumblelog.setText("rumbleLog");
		txtRumblelog.setBounds(10, 124, 430, 144);

		shell.open();
		shell.layout();
	}
}
